<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:a4j="http://richfaces.org/a4j"
                xmlns:rich="http://richfaces.org/rich"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:fn="http://java.sun.com/jsp/jstl/functions">

    <style type="text/css">
        .infoClass,.infoClass tr,.infoClass td{
            border-color: #ECF4FE;
            border-collapse:collapse;
            border-width: 1px;
        }

    </style>
    <h:form id="form1">
        <rich:panel header="预算审核" styleClass="content-hight">
            <rich:notifyMessage stayTime="3000"/>

            <h:panelGrid id="numberPer" columns="10" style="margin:-10px 0px 0px 0px;">
                第<h:outputText value="#{contractCheckBean.rowIndex+1}" style="color:red"/>条，
                共<h:outputText value="#{contractCheckBean.dataList.size()}" style="color:red;"/>条；
            </h:panelGrid>

            <rich:toolbar id="tolbar">
                <rich:toolbarGroup>
                    <a4j:commandButton value="首张" action="#{contractCheckBean.first}"
                                       execute="@this" render="@form"/>
                    <a4j:commandButton value="上一张" action="#{contractCheckBean.prev}"
                                       execute="@this" render="@form"/>
                    <a4j:commandButton value="下一张" action="#{contractCheckBean.next}"
                                       execute="@this" render="@form"/>
                    <a4j:commandButton value="末张"  action="#{contractCheckBean.last}"
                                       execute="@this" render="@form"/>
                    <h:commandButton value="返回列表" action="#{contractCheckBean.goBack}"/>
                </rich:toolbarGroup>
            </rich:toolbar>
            <div style="width:780px;overflow:auto;">
                <fieldset class="demo_fieldset">
                    <legend class="demo_legend">预算明细信息</legend>

                    <h:panelGrid id="mainEditGrid" columns="4"
                                 width="100%" styleClass="mainForm">
                        <h:outputLabel value="编号:" for="number"/>
                        <h:outputText  id="number" value="#{contractCheckBean.detail.number}"/>

                        <h:outputLabel value="类别：" for="typeName"/>
                        <h:outputText id="typeName" value="#{contractCheckBean.detail.contractTypeName}"/>

                        <h:outputLabel value="收付款类型："/>
                        <h:panelGroup id="isPayCon">
                            <h:outputText value="收款"
                                          rendered="#{contractCheckBean.detail.isPayCon eq 0}"/>
                            <h:outputText value="付款"
                                          rendered="#{contractCheckBean.detail.isPayCon eq 1}"/>
                            <h:outputText value="" 
                                          rendered="#{not(contractCheckBean.detail.isPayCon eq 0
                                                      or contractCheckBean.detail.isPayCon eq 1)}"/>
                        </h:panelGroup>

                        <h:outputLabel value="名称：" for="cname"/>
                        <h:outputText id="cname" value="#{contractCheckBean.detail.cname}"/>

                        <h:outputLabel value="签订日期" for="orderdate"/>
                        <h:outputText id="orderdate" value="#{contractCheckBean.detail.orderdate}">
                            <f:convertDateTime dateStyle="medium"/>
                        </h:outputText>

                        <h:outputLabel value="开始日期：" for="start"/>
                        <h:outputText id="start" value="#{contractCheckBean.detail.start}">
                            <f:convertDateTime dateStyle="medium"/>
                        </h:outputText>

                        <h:outputLabel value="截止日期：" for="deadline"/>
                        <h:outputText id="deadline" value="#{contractCheckBean.detail.deadline}">
                            <f:convertDateTime dateStyle="medium"/>
                        </h:outputText>

                        <h:outputLabel value="质保日期：" for="warranty"/>
                        <h:outputText id="warranty" value="#{contractCheckBean.detail.warranty}">
                            <f:convertDateTime dateStyle="medium"/>
                        </h:outputText>

                        <h:outputLabel value="甲方：" for="nameA"/>
                        <h:outputText id="nameA" value="#{contractCheckBean.detail.nameA}"/>

                        <h:outputLabel value="乙方：" for="nameB"/>
                        <h:outputText id="nameB" value="#{contractCheckBean.detail.nameB}"/>

                        <h:outputLabel value="甲方法人：" for="nameAstand"/>
                        <h:outputText id="nameAstand" value="#{contractCheckBean.detail.nameAstand}"/>

                        <h:outputLabel value="乙方法人：" for="nameBstand"/>
                        <h:outputText id="nameBstand" value="#{contractCheckBean.detail.nameBstand}"/>

                        <h:outputLabel value="地点：" for="address"/>
                        <h:outputText id="address" value="#{contractCheckBean.detail.address}"/>

                        <h:outputLabel value="标的：" for="target"/>
                        <h:outputText id="target" value="#{contractCheckBean.detail.target}"/>

                        <h:outputLabel value="质保金：" for="quality_margin"/>
                        <h:outputText id="quality_margin" value="#{contractCheckBean.detail.quality_margin}"/>

                        <h:outputLabel value="违约金：" for="penalty"/>
                        <h:outputText id="penalty" value="#{contractCheckBean.detail.penalty}"/>

                        <h:outputLabel value="预算项目：" for="projName"/>
                        <h:outputText id="projName" value="#{contractCheckBean.detail.projName}"/>

                        <h:outputLabel value="备注：" for="other"/>
                        <h:outputText  id="other" value="#{contractCheckBean.detail.other}"/>
                    </h:panelGrid>            
                </fieldset>

                <fieldset class="demo_fieldset">
                    <legend class="demo_legend">
                        审批历史
                    </legend>
                    <h:panelGroup id="check-mess">
                        <table class="infoClass" border="1" style="width:100%;">
                            <tr>
                                <td>
                                    <div style="text-align:center;font-weight:bolder;padding:3px 0px 3px 0px;white-space:nowrap">
                                        <h:outputText value="层级"/>
                                    </div>
                                </td>
                                <td>
                                    <div style="text-align:center;font-weight:bolder;padding:3px 0px 3px 0px">
                                        <h:outputText value="审批日期"/>
                                    </div>
                                </td>
                                <td>
                                    <div style="text-align:center;font-weight:bolder">
                                        <h:outputText value="审批人"/>
                                    </div>
                                </td>
                                <td>
                                    <div style="text-align:center;font-weight:bolder">
                                        <h:outputText value="审批角色"/>
                                    </div>
                                </td>
                                <td>
                                    <div style="text-align:center;font-weight:bolder">
                                        <h:outputText value="审批状态"/>
                                    </div>
                                </td>
                                <td>
                                    <div style="text-align:center;font-weight:bolder">
                                        <h:outputText value="审批意见"/>
                                    </div>
                                </td>
                            </tr>
                            <a4j:repeat value="#{contractCheckBean.historyFlowInfo}" var="info">
                                <tr style="background-color: inherit">
                                    <td>
                                        <div style="width:30px;text-align:center;font-weight:bolder;padding:3px 0px 3px 0px">
                                            <h:outputText value="#{info.checkLevel}"/>
                                        </div>
                                    </td>
                                    <td>
                                        <div style="text-align:center;white-space: nowrap;"> 
                                            <h:outputText value="#{info.checkdate}">
                                                <f:convertDateTime pattern="yyyy年MM月dd日 hh:mm" type="Date"/>
                                            </h:outputText>
                                        </div>
                                    </td>
                                    <td>
                                        <div style="padding-left: 10px;white-space: nowrap;">
                                            <h:outputText value="#{info.checkerName}"/>
                                        </div>
                                    </td>
                                    <td>
                                        <div style="width:50px;padding-left:10px;white-space: nowrap;">
                                            <h:outputText value="#{info.checkRoleName}"/>
                                        </div>
                                    </td>
                                    <td>
                                        <div style="width:60px;text-align:center">
                                            <h:outputText value="通过" rendered="#{info.isConfirm eq 1}"/>
                                            <h:outputText value="退回" rendered="#{info.isConfirm eq 2}" style="color: red"/>
                                            <h:outputText value="撤销审批" rendered="#{info.isConfirm eq 3}" style="color: red"/>
                                        </div>
                                    </td>
                                    <td>
                                        <rich:panel style="border:none;height:20px;">
                                            <div style="height: 20px;width:200px;padding-left:5px;margin-top: -7px;overflow:hidden;white-space: nowrap">
                                                <h:outputText value="#{info.content}" title="#{info.content}"/>
                                            </div>
                                        </rich:panel>
                                    </td>
                                </tr>
                            </a4j:repeat>
                        </table>
                    </h:panelGroup>
                </fieldset>
                <fieldset class="demo_fieldset">
                    <legend class="demo_legend">预算审核</legend>
                    <h:panelGroup id="checkGroup">
                        <h:panelGroup rendered="#{not contractCheckBean.checkAble}"
                                      layout="block" style="text-align: center;">                            
                            <h:outputText value="已审批" rendered="#{contractCheckBean.detail.billStatusForChecker eq '1'}"/>
                            <h:outputText value="等待上级审批" rendered="#{contractCheckBean.detail.billStatusForChecker eq '-2'}"/>
                            <h:outputText value="审批已结束" rendered="#{contractCheckBean.detail.billStatusForChecker eq '-1'
                                                                    or contractCheckBean.detail.billStatusForChecker eq '99'}"/>
                        </h:panelGroup>
                        <h:panelGroup rendered="#{contractCheckBean.checkAble}">
                            <rich:panel>
                                <h:panelGrid id="check" columns="1" width="500px">
                                    <h:outputLabel value="是否同意：" style="font-weight:bolder"/>
                                    <h:selectOneRadio value="#{contractCheckBean.currennode.isConfirm}"
                                                      style="margin-left:80px;"
                                                      disabled="#{!contractCheckBean.checkAble}">
                                        <f:selectItem itemValue="1" itemLabel="同意"/>
                                        <f:selectItem itemValue="2" itemLabel="不同意"/>
                                        <a4j:ajax event="click" execute="@this"
                                                  render="content,checkGroup" 
                                                  listener="#{contractCheckBean.contentListener}"/>
                                    </h:selectOneRadio>
                                </h:panelGrid>
                            </rich:panel>
                            <rich:panel id="content" style="margin-top:-1px;">
                                <h:outputLabel value="审批意见：" style="vertical-align:top;font-weight:bolder"/>
                                <h:inputTextarea cols="90" rows="6"
                                                 value="#{contractCheckBean.currennode.content}"
                                                 disabled="#{!contractCheckBean.checkAble}">
                                </h:inputTextarea>
                            </rich:panel>
                            <rich:panel style="margin-top:-1px;">
                                <h:panelGrid id="check1" columns="2" width="100%">
                                    <h:panelGrid columns="2">
                                        <h:outputLabel value="审批人：" style="font-weight:bolder"/>
                                        <h:outputLabel  value="#{contractCheckBean.currennode.checkerName}"/>
                                    </h:panelGrid>
                                    <h:panelGrid columns="2">
                                        <h:outputLabel value="审批日期：" style="font-weight:bolder"/>
                                        <h:outputLabel id="checkdate" value="#{contractCheckBean.currennode.checkdate}">
                                            <f:convertDateTime timeZone="GMT+8" pattern="yyyy-MM-dd HH:mm" dateStyle="medium"/>
                                        </h:outputLabel>
                                    </h:panelGrid>
                                </h:panelGrid>
                            </rich:panel>

                            <h:panelGroup layout="block" style="text-align: center;">
                                <a4j:commandButton value="审批" action="#{contractCheckBean.check}"
                                                   render="@form"
                                                   disabled="#{!contractCheckBean.checkAble}"
                                                   onclick="this.disabled = 'true';">
                                </a4j:commandButton>
                            </h:panelGroup>
                        </h:panelGroup>
                    </h:panelGroup>
                </fieldset>
                <h:panelGroup layout="block" style="text-align: center;">
                    <a4j:commandButton id="canclButton" value="取消审批"
                                       rendered="#{not contractCheckBean.checkAble}"
                                       action="#{contractCheckBean.cancelCheck}"
                                       disabled="#{not contractCheckBean.cancelAble}"
                                       execute="@this" render="@form"                                       
                                       onclick="this.disabled = 'true';">
                    </a4j:commandButton>
                </h:panelGroup>
            </div>
        </rich:panel>
    </h:form>
</ui:composition>
